chrome.runtime.onInstalled.addListener(() => {
  console.log('XTerm Controller 插件已安装');
});

// 点击插件图标时打开侧边栏
chrome.action.onClicked.addListener((tab) => {
  chrome.sidePanel.open({ tabId: tab.id });
});

// 处理来自content script的消息
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.type === 'OUTPUT_ANALYSIS') {
    // 转发分析结果到侧边栏
    chrome.runtime.sendMessage(request);
  }
});